<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>抽奖管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#name").focus();
			 var type = '${lottery.type}';
			 if(type =='') type ="1";
			 $("input[name='type'][value="+type+"]").attr("checked","checked");  
			 
			 var repeatType = '${lottery.repeatType}';
			 if(repeatType =='') repeatType ="1";
			 $("input[name='repeatType'][value="+repeatType+"]").attr("checked","checked");  
			 
			 var appointType = '${lottery.appointType}';
			 if(appointType =='') appointType ="1";
			 $("input[name='appointType'][value="+appointType+"]").attr("checked","checked");  
			 
			 
			 
			 var autoClear = '${lottery.autoClear}';
			 if(autoClear =='') autoClear ="0";
			 $("input[name='autoClear'][value="+autoClear+"]").attr("checked","checked");  
			 
			 
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			
			
			var rval=$('input:radio[name="appointType"]:checked').val()
			if(rval == '1'){
				$("#give").show();
				$("#worth").hide();
			}else{
				$("#worth").show();
				$("#give").hide();
			}
			
		});
		
		function changeScore(){
			
		}
		
		
		
		function showCardUrl(){
			$("#wechatCardUrl").show();
		}

		function hideCardUrl(){
			$("#wechatCardUrl").hide();
		}
		

		function showDiv(a){
			if(a == "give"){
				$("#give").show();
				$("#worth").hide();
			}else if(a == "worth"){
				$("#worth").show();
				$("#give").hide();
			}
		}
	</script>
	
	<style type="text/css">
		#give{display:none;}
		#worth{display:none;}
	</style>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/wechat/lottery/expandLotteryList?sourceId=${lottery.sourceId}&sourceType=3&type=7">三级推广奖品</a></li>
		<li class="active"><a href="${ctx}/wechat/lottery/expandLotteryForm?sourceId=${lottery.sourceId}&sourceType=3&type=7">三级推广奖品<shiro:hasPermission name="wechat:lottery:edit">${not empty lottery.id?'修改':'添加'}</shiro:hasPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="lottery" action="${ctx}/wechat/lottery/expandLotterySave" method="post" class="form-horizontal" enctype="multipart/form-data">
	
		<form:hidden path="id"/>
		<form:hidden path="user.id"/>
		<form:hidden path="type" value="7"/>
		<form:hidden path="lotteryType" value="1"/>
		<form:hidden path="sourceId" value="${lottery.sourceId}"/>
		<form:hidden path="sourceType" value="3"/>
		
		<tags:message content="${message}"/>
		<div class="control-group">
			<label class="control-label">名称:</label>
			<div class="controls">
				<form:input path="name" htmlEscape="false" maxlength="110" class="required"/>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">上传中奖图片:</label>
				<div class="controls">
					<c:if test="${not empty lottery.prizeimg && lottery.prizeimg ne ''}">
					<div class="control"><img src="${ctxUser }/images/${lottery.prizeimg}" style="width:100px;height:100px"/></div>
				   </c:if>
				<div class="control">
					<input type="file" name="diancanPicFile"  />    <span class="alert">大图片建议尺寸：720像素 * 400像素;  小图片建议尺寸：400像素 * 400像素 </span>      
				</div>
			</div>
		</div>
		
		
		<div class="control-group">
			<label class="control-label">领取区间上限:</label>
			<div class="controls">
				<form:input path="upper" htmlEscape="false" maxlength="11" class="digits"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">领取区间下限:</label>
			<div class="controls">
				<form:input path="lower" htmlEscape="false" maxlength="11" class="digits"/>
			</div>
		</div>
		
		<div class="control-group" id="worth">
			<label class="control-label">有效天数:</label>
			<div class="controls">
				<form:input path="appointDayNum" htmlEscape="false" maxlength="11" class="digits"/>  
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">备注:</label>
			<div class="controls">
				<form:textarea id="description" htmlEscape="true"   path="remarks" rows="4" maxlength="100000" class="input-xlarge required"/>
				<tags:ckeditor replace="description" uploadPath="/project" />
			</div>
		</div>
		
		<div class="form-actions">
			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>
